package com.itheima.zhuanhuan;

import java.util.TreeSet;

/*
- 用TreeSet集合存储多个学生信息(姓名,语文成绩,数学成绩,英语成绩),并遍历该集合
- 要求: 按照总分从高到低出现
        语文成绩
        数学成绩
        姓名
 */
public class Test02 {

    public static void main(String[] args) {
        TreeSet<Student> ts = new TreeSet<>((o1,o2)->{
            int result=o2.getALL()-o1.getALL();
            result=result==0?o2.getyScore()-o1.getyScore(): result;
            result=result==0?o2.getsScore()-o1.getsScore(): result;
            result=result==0?o2.getName().compareTo(o1.getName()): result;
            return result;

        });
        Student s1 = new Student("jack", 98, 100, 95);
        Student s4 = new Student("wack", 98, 100, 95);
        Student s2 = new Student("rose", 95, 95, 95);
        Student s3 = new Student("sam", 100, 93, 98);
        Student s5 = new Student("sem", 100, 94, 97);
        ts.add(s1);
        ts.add(s2);
        ts.add(s3);
        ts.add(s4);
        ts.add(s5);
        System.out.println(ts);
    }
}
